home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Games Machine 76
/
XENIATGM66.iso
/
Indiana Jones
/
Indiana Jones.exe
/
RESOURCE
/
PREVIEW.GOB
/
cog_riv_wolflanding.cog
< prev
next >
Wrap
Text File
|
1999-11-15
|
12KB
|
524 lines
# Jones 3D Cog Script
#
# olv_wolflanding.cog
#
# [SCHOLL]
#
# (C) 1999 LucasArts Entertainment Company LLC. All Rights Reserved
#
# ========================================================================================
symbols
message entered
message startup
message aievent
message arrivedwpnt
message timer
thing t_Wolf
thing t_Indy local
int n_eventType local
int n_CrntAIMode local
int n_OldAIMode local
int n_Waypoint local
flex f_DistToIndy local
int n_TimerID local
flex f_FleeTime local
int b_OKToStopFlee=0 local
int b_AttackOnStopFlee=0 local
int n_idx local
int b_WpntsActive=0 local
int n_FleeDir local
vector v_IndyPos local
vector v_WolfPos local
vector v_Temp local
# ===========================FLEE WAYPOINTS================================================
int NUM_FLEE_WAYPOINTS=27 local
thing t_Waypoint00
thing t_Waypoint01
thing t_Waypoint02
thing t_Waypoint03
thing t_Waypoint04
thing t_Waypoint05
thing t_Waypoint06
thing t_Waypoint07
thing t_Waypoint08
thing t_Waypoint09
thing t_Waypoint10
thing t_Waypoint11
thing t_Waypoint12
thing t_Waypoint13
thing t_Waypoint14
thing t_Waypoint15
thing t_Waypoint16
thing t_Waypoint17
thing t_Waypoint18
thing t_Waypoint19
thing t_Waypoint20
thing t_Waypoint21
thing t_Waypoint22
thing t_Waypoint23
thing t_Waypoint24
thing t_Waypoint25
thing t_Waypoint26
# ===========================SECTORS================================================
int NUM_AUTO_FLEE_SECTORS=1 local
sector s_AutoFlee00 mask=0x5 # need entered messages from wolf
int NUM_ACTIVATE_WPNT_SECTORS=2 local
sector s_ActivateWpnts00
sector s_ActivateWpnts01
int NUM_DEACTIVATE_WPNT_SECTORS=1 local
sector s_DeactivateWpnts00
# ===========================MISC CONSTANTS================================================
flex MIN_FLEE_DISTANCE=2.0 local # distance wolf wants to be from Indy before stopping fleeing
flex MIN_FLEE_RESTART_DISTANCE=1.0 local # distance wolf wants to be from Indy before stopping fleeing
flex MAX_FLEEATTACK_DISTANCE=1.0 local #
flex MIN_FLEE_TIME=4.0 local
flex VARIABLE_FLEE_TIME=3.0 local
int TIMER_ID_OKAY_TO_STOP_FLEE=0 local
int TIMER_ID_START_FLEE=1 local
int TIMER_ID_ATTACK=2 local
# ===========================SUBROUTINES================================================
flex SetDistToIndy local
flex ActivateWaypoints local
flex DeactivateWaypoints local
flex RankWaypointsForFlee local
flex RankWaypointsForFleeToSouth local
flex RankWaypointsForFleeToNorth local
flex ResetWaypointRanks local
end
# ========================================================================================
code
startup:
t_Indy=GetLocalPlayerThing();
call ActivateWaypoints;
return;
# ========================================================================================
entered:
if (GetSourceRef() == t_Indy)
{
for (n_idx = 0; n_idx < NUM_ACTIVATE_WPNT_SECTORS; n_idx = n_idx + 1)
{
if (GetSenderRef() == s_ActivateWpnts00[n_idx])
{
call ActivateWaypoints;
}
}
for (n_idx = 0; n_idx < NUM_DEACTIVATE_WPNT_SECTORS; n_idx = n_idx + 1)
{
if (GetSenderRef() == s_DeactivateWpnts00[n_idx])
{
call DeactivateWaypoints;
}
}
}
else if (GetSourceRef() == t_Wolf)
{
for (n_idx = 0; n_idx < NUM_AUTO_FLEE_SECTORS; n_idx = n_idx + 1)
{
if (GetSenderRef() == s_AutoFlee00[n_idx])
{
// DebugPrint("Wolf auto fleeing");
AIFlee(t_Wolf, t_Indy);
}
}
}
return;
# ========================================================================================
aievent:
n_eventType = GetParam(0);
n_CrntAIMode = GetParam(1);
n_OldAIMode = GetParam(2); // only valid for certain n_eventType values
if (n_eventType == 0x100) // SITHAI_EVENTMODECHANGED
{
// if changing to flee mode
// turn on waypoints
if ( !BITTEST(n_OldAIMode, 0x800) && BITTEST(n_CrntAIMode, 0x800) )
{
// DebugPrint("Entering flee mode");
AISetSubMode(t_Wolf, 0x8000); // SITHAI_SUBMODECONTINUOUSWPNTMOTION
f_FleeTime = (MIN_FLEE_TIME + (Rand() * VARIABLE_FLEE_TIME));
// DebugFlex( f_FleeTime, "Flee time");
SetTimerEx(f_FleeTime , TIMER_ID_OKAY_TO_STOP_FLEE, 0, 0 );
b_OKToStopFlee = 0;
call RankWaypointsForFlee;
}
// if exiting flee mode
// turn off waypoints
else if ( BITTEST(n_OldAIMode, 0x800) && !BITTEST(n_CrntAIMode, 0x800) )
{
call SetDistToIndy;
if (b_AttackOnStopFlee)
{
SetTimerEx(0.01 , TIMER_ID_ATTACK, 0, 0);
b_AttackOnStopFlee = 0;
AIClearSubMode(t_Wolf, 0x8000); // SITHAI_SUBMODECONTINUOUSWPNTMOTION
call ResetWaypointRanks;
}
// Consider restarting fleeing if Indy too close
else if (f_DistToIndy < MIN_FLEE_RESTART_DISTANCE)
{
// DebugFlex(f_DistToIndy, "Wolf restarting fleeing due to distance");
// Restart using timer to avoid nested mode changes
SetTimerEx(0.01 , TIMER_ID_START_FLEE, 0, 0 );
}
else
{
AIClearSubMode(t_Wolf, 0x8000); // SITHAI_SUBMODECONTINUOUSWPNTMOTION
call ResetWaypointRanks;
// DebugPrint("Exiting flee mode");
}
}
}
return;
# ========================================================================================
timer:
t_Indy = GetLocalPlayerThing();
n_TimerID = GetSenderID();
if (n_TimerID == TIMER_ID_OKAY_TO_STOP_FLEE)
{
b_OKToStopFlee = 1;
}
else if (n_TimerID == TIMER_ID_START_FLEE)
{
call RankWaypointsForFlee;
AIFlee(t_Wolf, t_Indy);
}
else if (n_TimerID == TIMER_ID_ATTACK)
{
AISetFireTarget(t_Wolf, t_Indy);
}
return;
# ========================================================================================
arrivedwpnt:
n_Waypoint = GetParam(0);
call SetDistToIndy;
if ( b_OKToStopFlee
&& (f_DistToIndy > MIN_FLEE_DISTANCE)
&& BITTEST(AIGetMode(t_Wolf), 0x800) // fleeing
&& (RandBetween(0,100) < 90)
)
{
// DebugFlex(f_DistToIndy, "Wolf stopping fleeing due to distance");
// StopThing before StopFlee so wolf will turn to face indy
StopThing(t_Wolf);
AIStopFlee(t_Wolf);
}
else if ( b_OKToStopFlee
&& (f_DistToIndy < MAX_FLEEATTACK_DISTANCE)
&& BITTEST(AIGetMode(t_Wolf), 0x800) // fleeing
&& (RandBetween(0,100) < 30)
)
{
// DebugFlex(f_DistToIndy, "Wolf stopping fleeing. Surprise attack");
b_AttackOnStopFlee = 1;
AIStopFlee(t_Wolf);
}
else if ( (n_FleeDir == -1)
&& BITTEST(AIGetMode(t_Wolf), 0x800) // fleeing
)
{
// fleeing south
if (n_Waypoint <=2)
{
if (f_DistToIndy > MIN_FLEE_RESTART_DISTANCE)
{
// StopThing before StopFlee so wolf will turn to face indy
// DebugPrint("Wolf Reached Flee Waypoint and Stopped.");
StopThing(t_Wolf);
AIStopFlee(t_Wolf);
}
else
{
// DebugFlex(f_DistToIndy, "Wolf Restarting fleeing.");
call RankWaypointsForFlee;
}
}
}
else if ( (n_FleeDir == 1)
&& BITTEST(AIGetMode(t_Wolf), 0x800) // fleeing
)
{
// fleeing south
if (n_Waypoint >=23)
{
if (f_DistToIndy > MIN_FLEE_RESTART_DISTANCE)
{
// StopThing before StopFlee so wolf will turn to face indy
// DebugPrint("Wolf Reached Flee Waypoint and Stopped.");
StopThing(t_Wolf);
AIStopFlee(t_Wolf);
}
else
{
// DebugFlex(f_DistToIndy, "Wolf Restarting fleeing.");
call RankWaypointsForFlee;
}
}
}
return;
# ========================================================================================
SetDistToIndy:
v_IndyPos = GetThingPos(t_Indy);
v_WolfPos = GetThingPos(t_Wolf);
f_DistToIndy = VectorDist(v_IndyPos, v_WolfPos);
return;
# ========================================================================================
ActivateWaypoints:
if (b_WpntsActive)
{
return;
}
// DebugPrint("ACTIVATING WAYPOINTS FOR WOLF IN LANDING AREA");
b_WpntsActive = 1;
AISetInstinctWpntMode(t_Wolf);
for ( n_idx = 0; n_idx < NUM_FLEE_WAYPOINTS; n_idx = n_idx + 1 )
{
AISetWpnt(t_Waypoint00[n_idx], n_idx);
}
AIConnectWpnts(0, 1);
AIConnectWpnts(0, 4);
AIConnectWpnts(0, 5);
AIConnectWpnts(1, 2);
AIConnectWpnts(1, 5);
AIConnectWpnts(1, 6);
AIConnectWpnts(2, 3);
AIConnectWpnts(2, 6);
AIConnectWpnts(3, 6);
AIConnectWpnts(3, 7);
AIConnectWpnts(4, 5);
AIConnectWpnts(4, 8);
AIConnectWpnts(5, 6);
// AIConnectWpnts(5, 8);
// AIConnectWpnts(5, 9);
AIConnectWpnts(6, 7);
// AIConnectWpnts(6, 8);
// AIConnectWpnts(6, 9);
// AIConnectWpnts(7, 8);
AIConnectWpnts(7, 9);
AIConnectWpnts(8, 9);
AIConnectWpnts(8, 11);
AIConnectWpnts(8, 12);
AIConnectWpnts(9, 12);
AIConnectWpnts(10, 11);
AIConnectWpnts(10, 13);
AIConnectWpnts(10, 14);
AIConnectWpnts(11, 12);
AIConnectWpnts(11, 14);
AIConnectWpnts(12, 14);
AIConnectWpnts(12, 16);
AIConnectWpnts(12, 19);
AIConnectWpnts(13, 14);
AIConnectWpnts(13, 15);
AIConnectWpnts(13, 16);
AIConnectWpnts(14, 15);
AIConnectWpnts(14, 16);
AIConnectWpnts(15, 16);
AIConnectWpnts(15, 17);
AIConnectWpnts(15, 18);
AIConnectWpnts(16, 17);
AIConnectWpnts(16, 18);
AIConnectWpnts(17, 18);
AIConnectWpnts(17, 21);
AIConnectWpnts(17, 23);
AIConnectWpnts(18, 19);
AIConnectWpnts(18, 20);
AIConnectWpnts(18, 21);
AIConnectWpnts(19, 20);
AIConnectWpnts(20, 21);
AIConnectWpnts(20, 22);
AIConnectWpnts(21, 22);
AIConnectWpnts(21, 23);
AIConnectWpnts(21, 24);
AIConnectWpnts(21, 25);
AIConnectWpnts(21, 26);
AIConnectWpnts(22, 25);
AIConnectWpnts(23, 24);
AIConnectWpnts(24, 26);
AIConnectWpnts(25, 26);
return;
# ========================================================================================
DeactivateWaypoints:
if (!b_WpntsActive)
{
return;
}
// DebugPrint("DEACTIVATING WAYPOINTS FOR WOLF LANDING");
b_WpntsActive = 0;
AIClearInstinctWpntMode(t_Wolf);
StopThing(t_Wolf);
return;
# ========================================================================================
RankWaypointsForFlee:
v_IndyPos = GetThingPos(t_Indy);
v_Temp = GetThingPos(t_Waypoint10);
if (VectorY(v_IndyPos) > VectorY(v_Temp))
{
call RankWaypointsForFleeToSouth;
}
else
{
call RankWaypointsForFleeToNorth;
}
return;
# ========================================================================================
RankWaypointsForFleeToSouth:
// DebugPrint("Rank waypoints for Flee To South");
n_FleeDir = -1;
AISetWpntRank(0, 135);
AISetWpntRank(1, 135);
AISetWpntRank(2, 135);
AISetWpntRank(3, 135);
AISetWpntRank(4, 120);
AISetWpntRank(5, 120);
AISetWpntRank(6, 120);
AISetWpntRank(7, 120);
AISetWpntRank(8, 105);
AISetWpntRank(9, 105);
AISetWpntRank(10, 90);
AISetWpntRank(11, 90);
AISetWpntRank(12, 90);
AISetWpntRank(13, 75);
AISetWpntRank(14, 75);
AISetWpntRank(15, 60);
AISetWpntRank(16, 60);
AISetWpntRank(17, 45);
AISetWpntRank(18, 45);
AISetWpntRank(19, 45);
AISetWpntRank(20, 30);
AISetWpntRank(21, 15);
AISetWpntRank(22, 15);
AISetWpntRank(23, 15);
AISetWpntRank(24, 0);
AISetWpntRank(25, 0);
AISetWpntRank(26, 0);
return;
RankWaypointsForFleeToNorth:
// DebugPrint("Rank waypoints for Flee To North");
n_FleeDir = 1;
AISetWpntRank(0, 0);
AISetWpntRank(1, 0);
AISetWpntRank(2, 0);
AISetWpntRank(3, 0);
AISetWpntRank(4, 15);
AISetWpntRank(5, 15);
AISetWpntRank(6, 15);
AISetWpntRank(7, 15);
AISetWpntRank(8, 30);
AISetWpntRank(9, 30);
AISetWpntRank(10, 45);
AISetWpntRank(11, 45);
AISetWpntRank(12, 45);
AISetWpntRank(13, 60);
AISetWpntRank(14, 60);
AISetWpntRank(15, 75);
AISetWpntRank(16, 75);
AISetWpntRank(17, 90);
AISetWpntRank(18, 90);
AISetWpntRank(19, 90);
AISetWpntRank(20, 105);
AISetWpntRank(21, 120);
AISetWpntRank(22, 120);
AISetWpntRank(23, 120);
AISetWpntRank(24, 135);
AISetWpntRank(25, 135);
AISetWpntRank(26, 135);
return;
# ========================================================================================
ResetWaypointRanks:
// DebugPrint("Reset waypoint ranks");
n_FleeDir = 0;
for ( n_idx = 0; n_idx < NUM_FLEE_WAYPOINTS; n_idx = n_idx + 1 )
{
AISetWpntRank(n_idx, 0);
}
return;
end